package tehUtils;

import java.util.Iterator;
import java.util.Set;

import tehUtils.Color;

import net.minecraft.client.Minecraft;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiControls;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.ModLoader;

public class GuiTest extends GuiScreen {
	
	private Minecraft mc = ModLoader.getMinecraftInstance();
	
	private static final int closeButton = 0;
	private Set results;
	
	
	public void initGui() {
		controlList.clear();
		//controlList.add(new GuiButton(closeButton, width - 120, 20, 20, 20, "X"));
		AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(mc.thePlayer.posX - 5, mc.thePlayer.posY - 5, mc.thePlayer.posZ - 5,
																mc.thePlayer.posX + 5, mc.thePlayer.posY + 5, mc.thePlayer.posZ + 5);
		results = BlockFinder.getBlocksInArea(searchArea);
	}
	
	public void drawScreen(int i, int j, float f) {
		drawBackground();

		int count = 0;
		for (Iterator iterator = results.iterator(); iterator.hasNext();) {
			if (count > 100) break;
			BlockInstance block = (BlockInstance)iterator.next();
			drawString(mc.fontRenderer, String.format("%d: %d", count, block.blockID), 5 + 35 * (int)Math.floor(count / 20), 5 + 10 * (count % 20), Color.white);
			count++;
		}
		
		super.drawScreen(i, j, f);
	}
	
	public void actionPerformed(GuiButton button) {
		switch (button.id) {
			case closeButton:
				close();
			break;
		}
	}
	
	public void drawBackground() {
		drawRect(0, 0, width, height, Color.black);
	}
	
	public void close() {
		mc.displayGuiScreen(null);
	}

}
